# SparkDebPackageConfig.cmake
# 
# 此模块用于 Debian 构建项目，即那些需要构建出 deb 软件包的项目。
# 本模块提供了一系列宏（函数）来简化寄生项目的构建和打包过程。
# 
# 使用方法：
# 1. 包含此模块
# 2. 使用 spark-deb-package.descript 文件定义软件包信息
# 3. 使用 add_package_descript 引入描述文件自动解析并自动化配置CPack
# 
# 注意： 确保在使用此模块之前已完成项目或组件的安装操作
# 
# 单包：在进行单包构建时，拥有默认行为
# 多包：在进行多包构建时，确保所有包都是组件化构建。
# 
# 如有特殊情况，请转用纯单包构建，或不使用此种构建
#

# 2024.07.07 NOTE: 
# 当下所有 SPARK_COMPONENT、SPARK_COMPONENT_DESCRIPTION 相关的内容都与 SparkParasiticBuild.cmake 有关

# find_str 函数用于在给定的字符串中查找匹配的子字符串，并返回其位置索引。
# 参数1: _IN  - 要搜索的字符串
# 参数2: _SEP - 要查找的子字符串
# 参数3: _OUT - 存储找到的子字符串的位置索引
function(find_str _IN _SEP _OUT)
    string(FIND "${_IN}" "${_SEP}" _TMP)
    set(${_OUT} ${_TMP} PARENT_SCOPE)
endfunction(find_str _IN _SEP _OUT)


function(find_next _IN _OUT)
    find_str("${_IN}" "\n" _TMP)
    set(${_OUT} ${_TMP} PARENT_SCOPE)
endfunction(find_next _IN _OUT)

function(sub_next _IN _INDEX _OUT __OUT)
    find_next(${_IN} _NEXTINDEX)
    string(SUBSTRING "${_IN}" ${_INDEX} ${_NEXTINDEX} _TMP)
    math(EXPR _NEXTINDEX ${_NEXTINDEX}+1)
    string(SUBSTRING "${_IN}" ${_NEXTINDEX} -1 __TMP)
    set(${_OUT} ${_TMP} PARENT_SCOPE)
    set(${__OUT} ${__TMP} PARENT_SCOPE)
endfunction(sub_next _IN _INDEX _OUT)

function(trim_str _IN _OUT)
    string(STRIP "${_IN}" _TMP)
    set(${_OUT} ${_TMP} PARENT_SCOPE)
endfunction(trim_str _IN _OUT)

function(split_str _IN _SEP _OUT)
    string(FIND "${_IN}" "${_SEP}" _TMP_INDEX)
    if(NOT _TMP_INDEX EQUAL -1)
        string(SUBSTRING "${_IN}" 0 ${_TMP_INDEX} _TMP)
        math(EXPR _TMP_INDEX ${_TMP_INDEX}+1)
        string(SUBSTRING "${_IN}" ${_TMP_INDEX} -1 __TMP)
        set(${_OUT} "${_TMP};${__TMP}" PARENT_SCOPE)
    else()
        set(${_OUT} ${_IN} PARENT_SCOPE)
    endif(NOT _TMP_INDEX EQUAL -1)
endfunction(split_str _IN _SEP _OUT)

function(split_str_p _IN _SEP _OUT __OUT)
    split_str("${_IN}" "${_SEP}" _TMP)
    list(GET _TMP 0 __TMP)
    list(GET _TMP 1 ___TMP)
    set(${_OUT} ${__TMP} PARENT_SCOPE)
    set(${__OUT} ${___TMP} PARENT_SCOPE)
endfunction(split_str_p _IN _SEP _OUT __OUT)

function(split_str_n _IN _SEP _OUT _N)
    if(_N GREATER 1)
        set(_C ${_N})
        set(_RET "")
        set(_NEXT ${_IN})
        while(NOT _C EQUAL 0)
            split_str("${_NEXT}" "${_SEP}" _TMP)
            list(LENGTH _TMP _TMP_LEN)
            if(_TMP_LEN EQUAL 2)
                list(GET _TMP 0 __TMP)
                list(GET _TMP 1 _NEXT)
                list(APPEND _RET ${__TMP})
            else()
                break()
            endif(_TMP_LEN EQUAL 2)
            math(EXPR _C "${_C}-1")
        endwhile(NOT _C EQUAL 0)
        list(APPEND _RET ${_NEXT})
        set(${_OUT} ${_RET} PARENT_SCOPE)
    else()
        split_str("${_IN}" "${_SEP}" _TMP)
        set(${_OUT} ${_TMP} PARENT_SCOPE)
    endif(_N GREATER 1)
endfunction(split_str_n _IN _SEP _OUT _N)


function(set_package_vars _IN_KEY _IN_VAL)

    # trim_str("${_IN_KEY}" _IN_KEY)

    find_str("${_IN_KEY}" "Type" _Type)
    if(_Type EQUAL "0")
        string(TOUPPER "${_IN_VAL}" _IN_VAL_UPPER)
        string(TOLOWER "${_IN_VAL}" _IN_VAL_LOWER)
        set(CPACK_GENERATOR "${_IN_VAL_UPPER}" PARENT_SCOPE)
        message("--> 软件包类型: ${_IN_VAL_LOWER}")
    endif(_Type EQUAL "0")

    find_str("${_IN_KEY}" "Package" _Package)
    # 如果找到了子字符串 "Package"
    if(_Package EQUAL "0")
        if(_IN_VAL STREQUAL "auto")
            set(CPACK_DEBIAN_PACKAGE_NAME "${PROJECT_NAME}" PARENT_SCOPE)
        else()
            set(CPACK_DEBIAN_PACKAGE_NAME "${_IN_VAL}" PARENT_SCOPE)
        endif(_IN_VAL STREQUAL "auto")
        if (SPARK_COMPONENT)
            set(CPACK_DEBIAN_${SPARK_COMPONENT}_NAME "${CPACK_DEBIAN_PACKAGE_NAME}" PARENT_SCOPE)
        endif(SPARK_COMPONENT)
        message("--> 软件包名: ${_IN_VAL}")
    endif(_Package EQUAL "0")

    find_str("${_IN_KEY}" "Version" _Version)
    # 如果找到了子字符串 "Version"
    if(_Version EQUAL "0")
        # 如果输入值 _IN_VAL 等于 "auto"
        if(_IN_VAL STREQUAL "auto")
            # 如果项目版本号为空
            if("" STREQUAL "${PROJECT_VERSION}")
                # 设置 Debian 软件包的版本为 "1.0"
                set(CPACK_DEBIAN_PACKAGE_VERSION "1.0" PARENT_SCOPE)
            else()
                # 否则，使用项目版本号作为 Debian 软件包的版本
                set(CPACK_DEBIAN_PACKAGE_VERSION "${PROJECT_VERSION}" PARENT_SCOPE)
            endif("" STREQUAL "${PROJECT_VERSION}")
        else()
            # 否则，使用输入值 _IN_VAL 作为 Debian 软件包的版本
            set(CPACK_DEBIAN_PACKAGE_VERSION "${_IN_VAL}" PARENT_SCOPE)
        endif(_IN_VAL STREQUAL "auto")

        # 输出软件版本信息
        message("--> 软件版本: ${_IN_VAL}")
    endif(_Version EQUAL "0")

    find_str("${_IN_KEY}" "CalVer" _CalVer)
    if(_CalVer EQUAL "0")
        set(CalVer "${_IN_VAL}" PARENT_SCOPE)
        message("--> 日历化版本: ${_IN_VAL}")
    endif(_CalVer EQUAL "0")

    find_str("${_IN_KEY}" "OSD" _OSDVer)
    if(_OSDVer EQUAL "0")
        set(OSDVer "${_IN_VAL}" PARENT_SCOPE)
        message("--> 声明发行版号: ${_IN_VAL}")
    endif(_OSDVer EQUAL "0")

    find_str("${_IN_KEY}" "Architecture" _Architecture)
    if(_Architecture EQUAL "0")
        set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${_IN_VAL}" PARENT_SCOPE)    
        if(_IN_VAL STREQUAL "auto")
            execute_process(
                COMMAND dpkg --print-architecture
                OUTPUT_VARIABLE _RETV
                OUTPUT_STRIP_TRAILING_WHITESPACE
            )
            set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${_RETV}" PARENT_SCOPE)
        endif(_IN_VAL STREQUAL "auto")
        if(SPARK_COMPONENT)
            set(CPACK_DEBIAN_${SPARK_COMPONENT}_PACKAGE_ARCHITECTURE "${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}" PARENT_SCOPE)
        endif(SPARK_COMPONENT)
        
        message("--> 软件架构: ${_IN_VAL}")
    endif(_Architecture EQUAL "0")
    
    find_str("${_IN_KEY}" "Priority" _Priority)
    if(_Priority EQUAL "0")
        set(CPACK_DEBIAN_PACKAGE_PRIORITY "${_IN_VAL}" PARENT_SCOPE)
        if(SPARK_COMPONENT)
            set(CPACK_DEBIAN_${SPARK_COMPONENT}_PACKAGE_PRIORITY "${CPACK_DEBIAN_PACKAGE_PRIORITY}" PARENT_SCOPE)
        endif(SPARK_COMPONENT)
        
        message("--> 优先级: ${_IN_VAL}")
    endif(_Priority EQUAL "0")

    find_str("${_IN_KEY}" "Depends" _Depends)
    if(_Depends EQUAL "0")
        set(CPACK_DEBIAN_PACKAGE_DEPENDS "${_IN_VAL}" PARENT_SCOPE)
        if(SPARK_COMPONENT)
            set(CPACK_DEBIAN_${SPARK_COMPONENT}_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}" PARENT_SCOPE)
        endif(SPARK_COMPONENT)
        
        message("--> 软件依赖: ${_IN_VAL}")
    endif(_Depends EQUAL "0")

    find_str("${_IN_KEY}" "Maintainer" _Maintainer)
    if(_Maintainer EQUAL "0")
        set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${_IN_VAL}" PARENT_SCOPE)
        message("--> 软件维护者: ${_IN_VAL}")
    endif(_Maintainer EQUAL "0")

    find_str("${_IN_KEY}" "Homepage" _Homepage)
    if(_Homepage EQUAL "0")
        set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "" PARENT_SCOPE)
        # 自动：使用 git 命令获取 Homepage
        if(_IN_VAL STREQUAL "auto")
            # 查找 git 命令
            find_program(GIT_EXECUTE git NO_CACHE)
            if(GIT_EXECUTE)
                # 判断是否处于 git 仓库
                execute_process(COMMAND git rev-parse --is-inside-work-tree
                    OUTPUT_VARIABLE _RETV
                    OUTPUT_STRIP_TRAILING_WHITESPACE
                    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
                )
                if(_RETV STREQUAL "true")
                    # 在 git 仓库中使用 git remote 命令获取远程地址
                    execute_process(
                        COMMAND git remote get-url origin 
                        OUTPUT_VARIABLE _RETV
                        OUTPUT_STRIP_TRAILING_WHITESPACE
                        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
                    )
                    set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${_RETV}" PARENT_SCOPE)
                endif(_RETV STREQUAL "true")
            endif(GIT_EXECUTE)
        else()
            set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${_IN_VAL}" PARENT_SCOPE)
        endif(_IN_VAL STREQUAL "auto")
        message("--> 软件主页: ${_IN_VAL}")
    endif(_Homepage EQUAL "0")

    find_str("${_IN_KEY}" "Recommends" _Recommends)
    if(_Recommends EQUAL "0")
        set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "${_IN_VAL}" PARENT_SCOPE)
        if(SPARK_COMPONENT)
            set(CPACK_DEBIAN_${SPARK_COMPONENT}_PACKAGE_RECOMMENDS "${CPACK_DEBIAN_PACKAGE_RECOMMENDS}" PARENT_SCOPE)  
        endif(SPARK_COMPONENT)
        
        message("--> 软件建议: ${_IN_VAL}")
    endif(_Recommends EQUAL "0")

    find_str("${_IN_KEY}" "Conflicts" _Conflicts)
    if(_Conflicts EQUAL "0")
        set(CPACK_DEBIAN_PACKAGE_CONFLICTS "${_IN_VAL}" PARENT_SCOPE)
        if(SPARK_COMPONENT)
            set(CPACK_DEBIAN_${SPARK_COMPONENT}_PACKAGE_CONFLICTS "${CPACK_DEBIAN_PACKAGE_CONFLICTS}" PARENT_SCOPE)
        endif(SPARK_COMPONENT)
        
        message("--> 软件冲突: ${_IN_VAL}")
    endif(_Conflicts EQUAL "0")
    
endfunction(set_package_vars _IN_KEY _IN_VAL)

# 定义一个自定义(add_package_descript)函数
# 用于按特定配置约定自动化构建软件包配置
function(add_package_descript IN_DES)
    set(PACKAGE_DES_PATH "${IN_DES}")

    if(EXISTS ${IN_DES})
        # set(PACKAGE_DES_PATH ${IN_DES})
    elseif(EXISTS ${CMAKE_CURRENT_LIST_DIR}/${IN_DES})
        set(PACKAGE_DES_PATH ${CMAKE_CURRENT_LIST_DIR}/${IN_DES})
    elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${IN_DES})
        set(PACKAGE_DES_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${IN_DES})
    elseif(EXISTS ${CMAKE_SOURCE_DIR}/cmake/_spark/spark.deb-package/cmake/spark-deb-package.descript)
        set(PACKAGE_DES_PATH ${CMAKE_SOURCE_DIR}/cmake/_spark/spark.deb-package/cmake/spark-deb-package.descript)
    else()
        message(FATAL_ERROR "!! Not Found Path: ${PACKAGE_DES_PATH}")
        return()
    endif(EXISTS ${IN_DES})
    
    file(READ ${PACKAGE_DES_PATH} DES_CONTENT)
    trim_str("${DES_CONTENT}" DES_CONTENT)

    ################## 解析 ##################

    sub_next(${DES_CONTENT} NEXT_INDEX DES_LINE DES_CONTENT)
    set(PREV_DES "")
    while(NOT DES_LINE STREQUAL "${PREV_DES}")
        # 检查该描述行是否是 # 注释开头，是的话将跳过该行
        find_str("${DES_LINE}" "#" _COMMENT)
        if(_COMMENT EQUAL "0")
            message("--> !!!!!!! ${DES_LINE}")
            sub_next(${DES_CONTENT} NEXT_INDEX DES_LINE DES_CONTENT)
            continue()
        endif(_COMMENT EQUAL "0")

        # 检查该描述行是否是 Descrition 开头，是的话说明描述结尾了
        find_str("${DES_LINE}" "Descrition" _DESCRIPTION)
        if(_DESCRIPTION EQUAL "0")
            break()
        endif(_DESCRIPTION EQUAL "0")

        split_str_n("${DES_LINE}" ":" _TMP 1)
        list(LENGTH _TMP _TMP_LEN)

        if(_TMP_LEN EQUAL 2)
            split_str_p("${DES_LINE}" ":" _TMP __TMP)
            trim_str("${__TMP}" __TMP)
            string(LENGTH "${__TMP}" __TMP_LENGTH)
            if(NOT __TMP_LENGTH EQUAL "0")
                set_package_vars("${_TMP}" "${__TMP}")
            endif(NOT __TMP_LENGTH EQUAL "0")
        endif(_TMP_LEN EQUAL 2)

        # 记录当前行，获取下一行，可能是已经结尾了(将保持重复行)
        set(PREV_DES "${DES_LINE}")
        sub_next(${DES_CONTENT} NEXT_INDEX DES_LINE DES_CONTENT)
    endwhile(NOT DES_LINE STREQUAL "${PREV_DES}")


    # 再一次检查该描述行是否是 Descrition 开头，是的话将进行分析描述行
    find_str("${DES_LINE}" "Descrition" _DESCRIPTION)
    if(_DESCRIPTION EQUAL "0")
        split_str_p("${DES_LINE}" ":" _TMP __TMP)
        trim_str("${__TMP}" __TMP)
        set(Descrition ${__TMP})
        set(PREV_DES_LINE "")
        while(NOT PREV_DES_LINE STREQUAL DES_LINE)
            if(NOT PREV_DES_LINE STREQUAL "")
                if ("${CMAKE_VERSION}" VERSION_LESS "3.15")
                    set(Descrition "${Descrition}\n${DES_LINE}")
                else()
                    string(STRIP "${DES_LINE}" STRIP_DES_LINE)
                    set(Descrition "${Descrition}\n${STRIP_DES_LINE}")
                endif("${CMAKE_VERSION}" VERSION_LESS "3.15")
            endif(NOT PREV_DES_LINE STREQUAL "")
            set(PREV_DES_LINE "${DES_LINE}")
            sub_next(${DES_CONTENT} NEXT_INDEX DES_LINE DES_CONTENT)
        endwhile(NOT PREV_DES_LINE STREQUAL DES_LINE)
        # set(Descrition "${Descrition}")
        message("--> 软件说明: ${Descrition}")

        set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${Descrition})
        if(SPARK_COMPONENT)
            set(CPACK_DEBIAN_${SPARK_COMPONENT}_DESCRIPTION ${Descrition})          
        endif(SPARK_COMPONENT)
    endif(_DESCRIPTION EQUAL "0")

    ##################### deb #####################
    # ARCHITECTURE
    if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
        set(ARCHITECTURE "amd64")
    elseif(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "aarch64")
        set(ARCHITECTURE "arm64")
    endif()

    #################### Calendar Version ###################
    if("${CalVer}" STREQUAL "true")
        string(TIMESTAMP BUILD_TIME "%Y%m%d")
        set(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_DEBIAN_PACKAGE_VERSION}-${BUILD_TIME}")
    endif("${CalVer}" STREQUAL "true")


    ####################### OS Release ######################
    if("${OSDVer}" STREQUAL "true")
        execute_process(COMMAND lsb_release -si
            OUTPUT_VARIABLE _OSI
            OUTPUT_STRIP_TRAILING_WHITESPACE
        )
        execute_process(COMMAND lsb_release -sr
            OUTPUT_VARIABLE _OSR
            OUTPUT_STRIP_TRAILING_WHITESPACE
        )
        if(NOT "${_OSI}" STREQUAL "" AND NOT "${_OSR}" STREQUAL "")
            set(PACKAGE_SUFFIX "_${_OSI}${_OSR}")
        endif(NOT "${_OSI}" STREQUAL "" AND NOT "${_OSR}" STREQUAL "")
    endif("${OSDVer}" STREQUAL "true")
    


    ##################### deb file name #####################
    set(_Package      "${CPACK_DEBIAN_PACKAGE_NAME}")
    set(_Version      "${CPACK_DEBIAN_PACKAGE_VERSION}")
    set(_Architecture "${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")

    if(SPARK_COMPONENT)
        # 作为组件化构建 deb 包时，使用自定义文件名
        set(_DebFileName 
            "${_Package}-${SPARK_COMPONENT}_${_Version}_${_Architecture}${PACKAGE_SUFFIX}.deb"
        )
        set(CPACK_DEBIAN_FILE_NAME                     "DEB-DEFAULT")
        set(CPACK_DEBIAN_${SPARK_COMPONENT}_FILE_NAME  ${_DebFileName})
    else()
        # 否则使用特殊化命名，当然如果没有特殊情况时，（见：标识 spark-deb-package）
        set(_DebFileName 
            "${_Package}_${_Version}_${_Architecture}${PACKAGE_SUFFIX}.deb"
        )
        set(CPACK_DEBIAN_FILE_NAME            ${_DebFileName})
    endif(SPARK_COMPONENT)
    message("-------- ${CPACK_DEBIAN_FILE_NAME}")

    # set(_DebFileName 
    #         "${_Package}-${SPARK_COMPONENT}_${_Version}_${_Architecture}${PACKAGE_SUFFIX}.deb"
    #     )
    # set(CPACK_DEBIAN_${SPARK_COMPONENT}_FILE_NAME            ${_DebFileName})
    
    ##################### deb file name #####################

    # 标识: spark-deb-package
    if(NOT "${PACKAGE_SUFFIX}" STREQUAL "")
        # eg: remove '_' of '_Debian' 
        string(SUBSTRING "${PACKAGE_SUFFIX}" 1 -1 DISTRIBUTION)
        if ("${CMAKE_VERSION}" VERSION_LESS "3.15")
            set(DESCRIPTION_SUFFIX "\n .\n Build for ${DISTRIBUTION} through spark-deb-build.")
        else()
            set(DESCRIPTION_SUFFIX "\n.\nBuild for ${DISTRIBUTION} through spark-deb-build.")
        endif("${CMAKE_VERSION}" VERSION_LESS "3.15")
    else()
        # 当没有任何特殊情况时，直接使用默认文件名规则
        # <PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
        # 如：bfdev_1.0.4-20240707_amd64.deb 
        set(CPACK_DEBIAN_FILE_NAME            "DEB-DEFAULT")
    endif(NOT "${PACKAGE_SUFFIX}" STREQUAL "")

    if(SPARK_COMPONENT)
        # 组件化多包构建时，将提供 SPARK_COMPONENT_DESCRIPTION 以用于组件描述
        set(SPARK_COMPONENT_DESCRIPTION "${Descrition}${DESCRIPTION_SUFFIX}" PARENT_SCOPE)
    else()
        set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${Descrition}${DESCRIPTION_SUFFIX}")
    endif(SPARK_COMPONENT)

    # set(CPACK_DEBIAN_PACKAGE_NAME         "${Package}")
        # 组件：CPACK_DEBIAN_<COMPONENT>_PACKAGE_NAME
    # set(CPACK_DEBIAN_PACKAGE_VERSION      "${Version}")
    # set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${Architecture}")
        # 组件：CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE
    # set(CPACK_DEBIAN_PACKAGE_DEPENDS      "${Depends}")
        # 组件：CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS
    # set(CPACK_DEBIAN_PACKAGE_PRIORITY     "${Priority}")
        # 组件：CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY
    # set(CPACK_DEBIAN_PACKAGE_MAINTAINER   "${Maintainer}")
    # set(CPACK_DEBIAN_PACKAGE_DESCRIPTION  "${Descrition}")
        # 组件：CPACK_DEBIAN_<COMPONENT>_DESCRIPTION (component based installers only)

    # 设置即将使用的标准脚本
    # set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
    #     "${CMAKE_SOURCE_DIR}/config/DEBIAN/preinst"
    #     "${CMAKE_SOURCE_DIR}/config/DEBIAN/postinst"
    #     "${CMAKE_SOURCE_DIR}/config/DEBIAN/prerm"
    #     "${CMAKE_SOURCE_DIR}/config/DEBIAN/postrm"
    # )

    # 设置为ON，以便使用 dpkg-shlibdeps 生成更好的包依赖列表。
    # set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
    # set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON)
    # set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY "=")

    include(CPack)

endfunction(add_package_descript IN_DES)


# TODO:
# CPACK_GENERATOR
# CPACK_DEBIAN_FILE_NAME                - n
# CPACK_DEBIAN_PACKAGE_NAME             - y
# CPACK_DEBIAN_PACKAGE_VERSION          - y
# CPACK_DEBIAN_PACKAGE_ARCHITECTURE     - y(auto) -> dpkg --print-architecture
# CPACK_DEBIAN_PACKAGE_DEPENDS          - y
# CPACK_DEBIAN_PACKAGE_PRIORITY         - y
# CPACK_DEBIAN_PACKAGE_MAINTAINER       - y
# CPACK_DEBIAN_PACKAGE_DESCRIPTION      - y

# ARCHITECTURE
# if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
#     set(ARCHITECTURE "amd64")
# elseif(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "aarch64")
#     set(ARCHITECTURE "arm64")
# endif()


# string(TIMESTAMP BUILD_TIME "%Y%m%d")
